home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 6366 / 6366.xpi / chrome / firegestures.jar / content / firegestures / viewSource.js < prev    next >
Text File  |  2009-11-17  |  2KB  |  71 lines

  1.  
  2. var FireGesturesViewSource = {
  3.  
  4.     _gestureHandler: null,
  5.  
  6.     _gestureMapping: null,
  7.  
  8.     init: function() {
  9.         var gestureSvc = Components.classes["@xuldev.org/firegestures/service;1"].
  10.                          getService(Components.interfaces.xdIGestureService);
  11.         this._gestureHandler = gestureSvc.createHandler();
  12.         this._gestureHandler.attach(getBrowser(), this);
  13.         this._gestureMapping = gestureSvc.getMapping("viewsource_mapping");
  14.     },
  15.  
  16.     uninit: function() {
  17.         if (this._gestureHandler) {
  18.             this._gestureHandler.detach();
  19.             this._gestureHandler = null;
  20.         }
  21.         this._gestureMapping = null;
  22.     },
  23.  
  24.  
  25.  
  26.     onDirectionChanged: function(event, aDirectionChain) {},
  27.  
  28.     onMouseGesture: function(event, aDirectionChain) {
  29.         var command = this._gestureMapping.getCommandForDirection(aDirectionChain);
  30.         if (command)
  31.             this._performAction(event, command.value);
  32.     },
  33.  
  34.     onExtraGesture: function(event, aGestureType) {
  35.         if (aGestureType == "gesture-timeout")
  36.             return;
  37.         this.onMouseGesture(event, aGestureType);
  38.     },
  39.  
  40.     _performAction: function(event, aCommand) {
  41.         switch (aCommand) {
  42.             case "cmd_scrollTop": 
  43.             case "cmd_scrollBottom": 
  44.             case "cmd_scrollPageUp": 
  45.             case "cmd_scrollPageDown": 
  46.                 goDoCommand(aCommand);
  47.                 break;
  48.             case "ViewSource:MinimizeWindow": 
  49.                 window.minimize();
  50.                 break;
  51.             case "ViewSource:MaximizeWindow": 
  52.                 window.windowState == window.STATE_MAXIMIZED ? window.restore() : window.maximize();
  53.                 break;
  54.             case "ViewSource:FireGestures": 
  55.                 this._gestureMapping.configure();
  56.                 break;
  57.             default: 
  58.                 var cmd = document.getElementById(aCommand);
  59.                 if (cmd && cmd.getAttribute("disabled") != "true")
  60.                     cmd.doCommand();
  61.         }
  62.     },
  63.  
  64. };
  65.  
  66.  
  67. window.addEventListener("load",   function(){ FireGesturesViewSource.init(); },   false);
  68. window.addEventListener("unload", function(){ FireGesturesViewSource.uninit(); }, false);
  69.  
  70.  
  71.